package com.nbsaas.boot.controller.shop;

import com.nbsaas.boot.rest.annotations.*;
import com.nbsaas.boot.rest.response.ListResponse;
import com.nbsaas.boot.rest.response.PageResponse;
import com.nbsaas.boot.rest.response.ResponseObject;
import com.nbsaas.boot.shop.api.domain.request.ShopBannerPositionRequest;
import com.nbsaas.boot.shop.api.domain.request.ShopBannerPositionSearch;
import com.nbsaas.boot.shop.api.domain.response.ShopBannerPositionResponse;
import com.nbsaas.boot.shop.api.domain.simple.ShopBannerPositionSimple;
import com.nbsaas.boot.shop.api.apis.ShopBannerPositionApi;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestBody;
import javax.annotation.Resource;

/**
*  广告位控制器
*/
@RequiresAuthentication
@RestController
@RequestMapping("/shopBannerPosition")
public class ShopBannerPositionController {


    @Resource
    private ShopBannerPositionApi shopBannerPositionApi;

    /**
    * 搜索数据
    *
    * @param request
    * @return
    */
    @SearchData
    @RequiresPermissions("shopBannerPosition")
    @PostMapping("/search")
    public PageResponse <ShopBannerPositionSimple> search(@RequestBody ShopBannerPositionSearch request) {
        return shopBannerPositionApi.search(request);
    }

    /**
    * 列表数据
    *
    * @param request
    * @return
    */
    @SearchData
    @RequiresPermissions("shopBannerPosition")
    @PostMapping("/list")
    public ListResponse<ShopBannerPositionSimple> list(@RequestBody ShopBannerPositionSearch request) {
        return shopBannerPositionApi.list(request);
    }

    /**
    * 添加数据
    *
    * @param request
    * @return
    */
    @RequiresPermissions("shopBannerPosition")
    @CreateData
    @PostMapping("/create")
    public ResponseObject <ShopBannerPositionResponse> create(@RequestBody @Validated(AddOperator.class) ShopBannerPositionRequest request) {
        return shopBannerPositionApi.create(request);
    }

   /**
   * 修改数据
   * @param request
   * @return
   */
   @RequiresPermissions("shopBannerPosition")
   @UpdateData
   @PostMapping("/update")
   public ResponseObject<ShopBannerPositionResponse> update(@RequestBody @Validated(UpdateOperator.class) ShopBannerPositionRequest request) {
       return shopBannerPositionApi.update(request);
   }

    /**
    * 删除数据
    *
    * @param request
    * @return
    */
    @SearchData
    @RequiresPermissions("shopBannerPosition")
    @PostMapping("/delete")
    public ResponseObject<?> delete(@RequestBody @Validated(DeleteOperator.class) ShopBannerPositionRequest request) {
        return shopBannerPositionApi.delete(request);
    }

    /**
    * 查看数据
    *
    * @param request
    * @return
    */
    @SearchData
    @RequiresPermissions("shopBannerPosition")
    @PostMapping("/view")
    public ResponseObject <ShopBannerPositionResponse> view(@RequestBody @Validated(ViewOperator.class) ShopBannerPositionRequest  request) {
        return shopBannerPositionApi.view(request);
    }
}